//
//  YXPartnerListTableView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/23.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXPartnerListTableView.h"

#import "YXPartnerCell.h"
@interface YXPartnerListTableView ()<UITableViewDelegate ,UITableViewDataSource>

@end

@implementation YXPartnerListTableView

- (void)setListArr:(NSArray *)listArr {
    _listArr = listArr;
    
    [self reloadData];
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    if (self = [super initWithFrame:frame style:style]) {
        self.backgroundColor = color_backColor;
        self.separatorStyle = UITableViewCellSelectionStyleNone;
        self.delegate = self;
        self.dataSource = self;
        [self registerNib:[UINib nibWithNibName:@"YXPartnerCell" bundle:nil] forCellReuseIdentifier:@"YXPartnerCell"];
        
    }
    return self;
}

#pragma mark - UITableView Delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.listArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YXPartnerCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YXPartnerCell" forIndexPath:indexPath];
    cell.model = self.listArr[indexPath.section];
    [cell setClickPhoneBtnBlock:^(YXPartnerCell *cell, YXUserInfoModel *model) {
        self.selectPhoneBtnBlock(model.name, model.phone);
    }];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] init];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    YXUserInfoModel *model = self.listArr[indexPath.section];

    if (self.selectRowAtIndexPath) {
        self.selectRowAtIndexPath(model);
    }
}



@end
